import { sphHttp } from '@/utils/request.ts'
import { LoginRes, ReqLoginParams, ReqRegisterParams, UserInfo } from '@/types/user'

/**
 * @description 获取验证码
 * @param phone
 */
export const reqCode = (phone: string) => {
   return sphHttp<string>(`/api/user/passport/sendCode/${phone}`, 'GET')
}

/**
 * @description 请求注册
 * @param params
 */
export const reqRegister = (params: ReqRegisterParams) => {
   return sphHttp('/api/user/passport/register', 'POST', params)
}

/**
 * @description 请求登录
 * @param params
 */
export const reqLogin = (params: ReqLoginParams) => {
  return sphHttp<LoginRes>('/api/user/passport/login', 'POST', params)
}

/**
 * @description 退出登录
 */
export const reqLogOut = () => {
  return sphHttp<string>('/api/user/passport/logout', 'GET')
}

/**
 * @description 获取用户信息
 */
export const reqUserInfo = () => {
   return sphHttp<UserInfo>('/api/user/passport/auth/getUserInfo', 'GET')
}
